<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <ul>
      <!-- 由于v-for循环生成的是虚拟dom  在操作dom删除 等操作时 会发生错乱 
      给每个克隆产生的虚拟dom 绑定唯一标识
     唯一标识 可以是数据下标index  或数据中的id等唯一数据 
    v-bind:key="index"  v-bind:key="item.id" -->
      <li v-for="(item,index) in arr" v-bind:key="index">{{item}}</li>
    </ul>
    <ul>
      <!-- <li v-for="item in obj">{{item}}</li> -->
      <!-- v-bind:key="index" 简写 :key="index" -->
      <!-- item代表每一项的值   key 代表对象key  index下标 -->
      <li v-for="(item,key,index) in obj" :key="index">
        {{index}} -----{{key}} -----{{item}}
      </li>
    </ul>
    <!-- v-for 渲染最常见的 数组包对象的数据类型 -->
    <ul>
      <li v-for="(item,index) in prolist" :key="item.id">
        <p>{{item.id}}</p>
        <p>{{item.pname}}</p>
        <div>
          {{item.price}}
        </div>
        <div v-for="(skuItem,index) in item.sku">
          颜色：<span>{{skuItem.color}}</span> 尺寸：<span>{{skuItem.size}}</span>
        </div>
      </li>
    </ul>
    <!-- 循环固定次数 -->
    <ul>
      <!-- n 从1 开始 到10 -->
      <li v-for="n in 10" :key="n">
        {{n}}等奖
      </li>
    </ul>
  </div>
  <script src="./vue.js"></script>
  <script>
    var vm = new Vue({
      el: "#app",
      data() {
        return {
          arr: ["孙尚香", "诸葛亮", "后裔", "米州", "米莱迪"],
          obj: {
            city: "北京",
            people: "3000万",
            eat: "糖葫芦",
            he: "燕京"
          },
          prolist: [{
            id: 1,
            pname: "火车",
            price: 2000,
            sku: [
              { color: "白色", size: 1888 },
              { color: "红色", size: 1999 }
            ]
          },
          {
            id: 2,
            pname: "高铁",
            price: 4000,
            sku: [
              { color: "蓝色", size: 5000 },
              { color: "紫色", size: 6000 }
            ]
          },
          {
            id: 3,
            pname: "飞机",
            price: 8000,
            sku: [
              { color: "黑色", size: 7888 },
              { color: "黄色", size: 7999 }
            ]
          }
          ]
        }
      }
    })


  </script>


</body>

</html>